﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UPMS.Core.Domain.Mapping
{
    public class UserMap : BaseMap<User>
    {
        public UserMap()
        {
            this.ToTable("Upms_tbl_User");

            this.Property(u => u.UserName).HasColumnName("UserName").IsRequired().HasMaxLength(64);
            this.Property(u => u.UserType).HasColumnName("UserType").IsRequired();

            this.HasMany(u => u.Accounts).WithMany(a => a.Users)
              .Map(m =>
              {
                  m.ToTable("Upms_tbl_User_Account");
                  m.MapLeftKey("UserId");
                  m.MapRightKey("AccountId");
              });

        }
    }
}
